// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
var FishBase = require("FishBase");

cc.Class({
    extends: cc.Component,

    properties: {
        isBusy: false,
        curFish: {
            default: null,
            type: FishBase
        }
    },


    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        this.initCollider();
    },
    initCollider: function() {
        cc.director.getCollisionManager().enabled = true;
        cc.director.getCollisionManager().enabledDebugDraw = true;
        cc.director.getCollisionManager().enabledDrawBoundingBox = true;
    },

    onCollisionEnter: function(other) {
        var self = this;
        self.curFish = other.getComponent("FishBase");
        cc.log(self.curFish.isTracked);
        self.curFish.isTracked = true;
        self.isBusy = true;
    },

    onCollisionStay: function(other) {
        // console.log('on collision stay');
        // this.isBusy = true;
    },

    onCollisionExit: function() {
         this.node.color = cc.Color.WHITE;
         // this.isBusy = true;
    },

    start() {

    },

    update (dt) {
        var self = this;
        if(self.isBusy){
            // var temp = 
            self.curFish.updatePositionBy(this.node.position);
        }

    },
});